/** 1
   / \
  2   2
 / \ / \
3  4 4  3  二叉树 [1,2,2,3,4,4,3] 是对称的。
输入：root = [1,2,2,3,4,4,3]
输出：true
 * Definition for a binary tree node.
 * function TreeNode(val) {
 *     this.val = val;
 *     this.left = this.right = null;
 * }
 */
/**
 * @param {TreeNode} root
 * @return {boolean}
 */
var isSymmetric = function (root) {
    function isMirror(r1, r2) {
        if (!r1 && !r2) return true;//没有
        if (!r1 || !r2) return false;//有一个有

        return r1.val === r2.val && isMirror(r1.left, r2.right) && isMirror(r1.right, r2.left)
    }

    return isMirror(root, root);

};